/*
 * @Description: sort()数组排序
 * @Author: zzj
 * @Date: 2021-09-08 20:03:37
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-08 20:03:38
 */

var arr = [11,5,23,7,4,1,9,1];   
console.log(arr.sort(compare));   
function compare(v1,v2){    
    if(v1>v2){return -1;}     
    else if( v1<v2){return 1;}
    else{return 0;}
}